public class RunnableDemo {
    private static int total=0;
    public static void main(String[] args) throws InterruptedException {
        Runnable r = new Runnable(){
            int sum=0;
            public void run() {
                for (int i = 0; i <=100 ; i++) {
                    sum+=i;
                }
                total=sum;
            }
        };
        Thread t1 = new Thread(r);
        t1.start();
        t1.join();
        System.out.println(total);
    }
}
